/**
 *  @author Ion Morozan
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.dddforandroid.design;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;

import com.dddforandroid.database.R;
import com.dddforandroid.database.local.CreateNote;
import com.dddforandroid.database.server.SyncServerDatabase;


public class AddTaskActivity extends Activity {

    /**/
    private SyncServerDatabase nosql;

	public static ProgressDialog progress;
	
    /**
     * Called when the activity is first created
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.add_task);

    	/* The EditText used*/
        final EditText nameET, noteET;
        final DatePicker datePk;
        
        nameET = (EditText) findViewById(R.id.name);
        noteET = (EditText) findViewById(R.id.note);
        datePk = (DatePicker) findViewById(R.id.pickDate);
        
        /* Do not show the keyboard when editing the EditText*/
        nameET.setInputType(InputType.TYPE_NULL);

        Button add = (Button)findViewById(R.id.createButton);
        
        nosql = new SyncServerDatabase();
        /* Listener for the Add Button*/
        add.setOnClickListener(new OnClickListener() {
         	public void onClick(View v){
         		progress = ProgressDialog.show(AddTaskActivity.this, "",
						"Adding data to database...");
         		new CreateNote(nameET, noteET, datePk, getApplicationContext(), 
         				nosql, CurrentTasksActivity.authClient).execute();
        	}
        });
        
        
    }
       
}
  

